package com.licky.base;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    private Boolean flag;
    private String message;
    private Integer code;
    private T data;

    public Result() {
    }

    public Result (Boolean flag, String message, Integer code, T data) {
        this.flag = flag;
        this.message = message;
        this.code = code;
        this.data = data;
    }

    public Result(Boolean flag, String message, Integer code) {
        this.flag = flag;
        this.message = message;
        this.code = code;
    }

    public Result(Boolean flag, String message) {
        this.flag = flag;
        this.message = message;
    }

    public Result(Boolean flag) {
        this.flag = flag;
    }

    public static <T> Result<T> success(T  data){
        return new Result(true, "操作成功", 200, data);
    }

    public static Result success(){
        return new Result(true, "操作成功", 200);
    }

    public static Result error(String message){
        return new Result(false, message, 500);
    }
}
